/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unesp.demac.bcc.soo.clarus.util;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author aluno
 */
public class FrameUtil {

    private FrameUtil() {
    }

    public static void centralizar(JFrame f) {
        Dimension screenSize =
                Toolkit.getDefaultToolkit().getScreenSize();
        f.setLocation(
                (screenSize.width - f.getWidth()) / 2,
                (screenSize.height - f.getHeight()) / 2);
    }

    public static void centralizar(JDialog f) {
        Dimension screenSize =
                Toolkit.getDefaultToolkit().getScreenSize();
        f.setLocation(
                (screenSize.width - f.getWidth()) / 2,
                (screenSize.height - f.getHeight()) / 2);
    }

    public static void setLook(JFrame f) {
        final String lfname = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
        
        try {
            UIManager.setLookAndFeel(lfname);
        } catch (ClassNotFoundException ex) {
            ex.getMessage();
        } catch (IllegalAccessException ex) {
            ex.getMessage();
        } catch (InstantiationException ex) {
            ex.getMessage();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.getMessage();
        }

        SwingUtilities.updateComponentTreeUI(f);
    }
}
